<?php if(isset($event_locked)) : ?>
	<div class="table-header">
	       Event Locked
	    </div>
	    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
	        <thead>
	                <tr>
	                    <th width="20"></th>
	                    <th>Event Code</th>
	                    <th>Main Title</th>
	                    <th>Category</th>
	                    <th>Status</th>
	                    <th>User</th>
	                    <th>User Email</th>
	                    <!-- <th>Ticket Code</th>
	                    <th width="50">Payment Type</th>
	                    <th>Status</th>
	                    <th>Payment</th>
	                    <th>Book date</th>
	                    <th width="20"></th> -->
	                </tr>
	        </thead>

	        <tbody>
	             <?php
	                    if (isset($event_locked)):
	                        foreach ($event_locked as $k=> $event) :
	              ?>
	                <tr>
	                    <td class="center">
	                        <label>
	                            <?php echo $k+1; ?>
	                        </label>
	                    </td>
	                    <td>
	                    	<b class="blue">
	                        	<?php echo $event->event_code ?>
	                        </b>
	                    </td>
	                    <td>
	                    	<b class="green">
	                        	<?php echo $event->translate[1]['main_title']; ?>
	                        </b>
	                    </td>
	                    <td>
	                    	<b>
	                        	<?php echo $event->category['name']; ?>
	                        </b>
	                    </td>
	                    <td>
	                    	<a href="#" onclick="unlock(<?php echo $event->id; ?>)" title="Click here to unlock event">
	                    		<span class="label label-important">
		                        	Locked
		                        </span>
	                    	</a>             	
	                    </td>
	                    <td>
	                    	<b class="green">
	                        	<?php $user = MyFunctionCustom::get_user_info($event->user_lock); ?>
	                        	<?php echo $user->first_name . ' ' . $user->last_name; ?>
	                        </b>
	                    </td>
	                    <td>
	                    	<b>
	                        	<?php echo $user->email; ?>
	                        </b>
	                    </td>
	                </tr>
	            <?php endforeach;endif; ?>
	        </tbody>
	    </table>
<?php endif; ?>
<?php if(isset($booked_locked)) : ?>
	<div class="table-header">
       Booked Locked
    </div>
    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
        <thead>
                <tr>
                    <th width="20"></th>
                    <th>Event Main Title</th>
                    <th>Ticket Order Number</th>
                    <th width="50">Payment Type</th>
                    <th>Booked Status</th>
                    <th>Lock Status</th>
                    <th>User</th>
                    <th>User email</th>
                    <th>Payment</th>
                    <th>Book date</th>
                </tr>
        </thead>

        <tbody>
             <?php
                    if (isset($booked_locked)):
                        foreach ($booked_locked as $k=> $booked) :
              ?>
                <tr>
                    <td class="center">
                        <label>
                            <?php echo $k+1; ?>
                        </label>
                    </td>
                    <td>
                    	<?php $result = MyFunctionCustom::getInfoEvent($booked->event_id,2); ?>
                        <?php if($result == null) : ?>
                            <span class="label label-important label-mini" title="This event has been deleted by user">Deleted</span>
                        <?php else : ?>
                            <?php echo $result; ?>
                        <?php endif; ?>
                        
                    </td>
                    <td>
                    	<b class="blue">
                    		<?php echo $booked->ticket_order_number; ?>
                    	</b>
                        
                    </td>
                    <td>
                    	<b class="green"><?php echo MyFunctionCustom::getPayment($booked->payment_type); ?></b>                     
                    </td>
                    <td>
                    	<?php
                            $stt = MyFunctionCustom::getStatusBooking($booked->status);
                        ?>                      
                        <?php if($booked->status==STATUS_PENDING) : ?>
                            <span class="label label-important label-mini" title="Change status"><?php echo $stt; ?></span>
                        <?php elseif($booked->status == STATUS_DELIVER): ?>
                            <span class="label label-info label-mini" title="Change status"><?php echo $stt; ?></span>
                        <?php else: ?>
                               <span class="label label-success label-mini" title="Finished"><?php echo $stt; ?></span>
                        <?php endif; ?>
                    </td>
                    <td>
                    	<a href="#" onclick="unlock_booked(<?php echo $booked->id; ?>)" title="Click here to unlock booked order">
                    		<span class="label label-important">
	                        	Locked
	                        </span>
                    	</a>
                        
                    </td>
                    <td>
                    	<b class="green">
                        	<?php $user = MyFunctionCustom::get_user_info($booked->user_lock); ?>
                        	<?php echo $user->first_name . ' ' . $user->last_name; ?>
                        </b>
                    </td>
                    <td>
                    	<b>
                        	<?php echo $user->email; ?>
                        </b>
                    </td>
                    <td><b class="green">Yes</b></td>
                    <td>
                        <?php echo date('h:i / d-M-Y',  strtotime($booked->booked_time)); ?>
                    </td>
                </tr>
            <?php endforeach;endif; ?>
        </tbody>
    </table>
<?php endif; ?>
<script type="text/javascript">
	function unlock_booked(id){
		$.ajax({
			url: '<?php echo Yii::app()->createAbsoluteUrl("bookingsystem/eventlocked/unlockevent") ?>',
			data: {booked_id : id},
			type:'POST',
			beforeSend: function(){
				$('#tab_book').empty();
				$('#tab_book').append('<div class="loading"><div style="width:134px;height:100px;margin:0 auto;padding-top: 10px;"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/frontend/images/ajaxloader.gif"></div></div>');
			},
			success: function(data){
				window.location.reload();
			}
		});
	}
</script>